import 'package:lib_uikit/theme/gt_theme_provider.dart';

extension GTStringRTLAdapt on String {
  /// 适配某些场景字符串在RTL环境显示异常的问题
  /// 例如：
  ///   1. '500K USDT' 显示为 '500K USDT' 适配显示为 'USDT 500K'
  ///   2. '+7.02 USD (+0.26%)' 显示为 'USD (+0.26%) +7.02+' 适配显示为 '(0.26%+) USD 7.02+'
  String get gtRTLAdapt {
    if (GTThemeProvider.instance.isRTL()) {
      /// Unicode "Left-To-Right Embedding" (LRE) character. '\u202A'
      /// Unicode "Right-To-Left Embedding" (RLE) character. '\u202B'
      /// Unicode "Pop Directional Formatting" (PDF) character. '\u202C'
      /// Unicode "Left-To-Right Mark" (LRM) character. '\u200E'
      /// Unicode "Right-To-Left Mark" (RLM) character. '\u200F'
      return split(' ').map((e) => '\u200F$e\u200F').join(' ');
    }
    return this;
  }
}
